﻿<UserControl x:Class="ForumsBrowser.NewThreadNotification"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:fb="clr-namespace:ForumsBrowser">
    <UserControl.Resources>
        <ResourceDictionary>
            <Storyboard x:Key="shrink">
                <DoubleAnimation Duration="0:0:0.5" To="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=ActualHeight, Converter={StaticResource DoublePercentConverter}, ConverterParameter=2}" Storyboard.TargetProperty="Height"/>
                <DoubleAnimation BeginTime="0:0:0.5" Duration="0:0:0.5" To="0" Storyboard.TargetProperty="Height"/>
            </Storyboard>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="DefaultStyle.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid HorizontalAlignment="Left" Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualHeight}"
               Height="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualHeight}"
              >
            <Grid.RenderTransform>
                <TranslateTransform X="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualHeight, Converter={StaticResource DoublePercentConverter}, ConverterParameter=-.4}"
                    Y="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualHeight, Converter={StaticResource DoublePercentConverter}, ConverterParameter=-.55}"/>
            </Grid.RenderTransform>
            <Polygon HorizontalAlignment="Center" x:Name="Glimmer" VerticalAlignment="Center" RenderTransformOrigin=".5,.5"
                     Height="0"
                     Points="100,0,105,45,150,50,105,55,100,100,95,55,50,50,95,45" Stroke="White" Width="{Binding ElementName=Glimmer, Path=Height}" Stretch="Uniform">
                <Polygon.RenderTransform>
                    <TransformGroup>
                        <RotateTransform x:Name="rotate" Angle="0">
                        </RotateTransform>
                        <TranslateTransform x:Name="translate" X="0" Y="0"/>
                    </TransformGroup>
                </Polygon.RenderTransform>
                <Polygon.Effect>
                    <DropShadowEffect Color="Gold" ShadowDepth="5" BlurRadius="8"/>
                </Polygon.Effect>
                <Polygon.Fill>
                    <RadialGradientBrush RadiusX="1" RadiusY="1">
                        <RadialGradientBrush.GradientStops>
                            <GradientStop Offset="0" Color="White"/>
                            <GradientStop Offset=".3" Color="Yellow"/>
                        </RadialGradientBrush.GradientStops>
                    </RadialGradientBrush>
                </Polygon.Fill>
                <Polygon.Triggers>
                    <EventTrigger RoutedEvent="Polygon.Loaded" >
                        <BeginStoryboard>
                            <Storyboard BeginTime="0:0:1" Duration="0:0:2" DecelerationRatio=".6" >
                                <DoubleAnimation Storyboard.TargetName="rotate" RepeatBehavior="Forever" Storyboard.TargetProperty="Angle" BeginTime="0:0:0" Duration="0:0:0.2" From="0" To="359"/>
                                <DoubleAnimation Storyboard.TargetName="translate" Duration="0:0:2" Storyboard.TargetProperty="X" BeginTime="0:0:0" From="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl} }, Path=Parent.ActualWidth}" To="0"/>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                    <EventTrigger RoutedEvent="Polygon.Loaded">
                        <BeginStoryboard>
                            <Storyboard BeginTime="0:0:1" Duration="0:0:3" x:Name="flyinStoryboard">
                                <DoubleAnimation BeginTime="0:0:0" AccelerationRatio=".8" Storyboard.TargetProperty="Height" Duration="0:0:2" 
                                                 From="0" 
                                                 To="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualHeight}" />
                                <DoubleAnimation BeginTime="0:0:2" Storyboard.TargetProperty="Height" Duration="0:0:0.5" 
                                                 From="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualHeight}" 
                                                 To="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualHeight, Converter={StaticResource DoublePercentConverter}, ConverterParameter=.25}" />
                                <DoubleAnimation BeginTime="0:0:2.5" Storyboard.TargetProperty="Height" Duration="0:0:0.25" 
                                                 From="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualHeight, Converter={StaticResource DoublePercentConverter}, ConverterParameter=.25}" 
                                                 To="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualHeight}" />
                                <DoubleAnimation BeginTime="0:0:2.75" Storyboard.TargetProperty="Height" Duration="0:0:0.25" 
                                                 From="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualHeight}"  
                                                 To="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualHeight, Converter={StaticResource DoublePercentConverter}, ConverterParameter=.5}" />
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Polygon.Triggers>
            </Polygon>
        </Grid>
    </Grid>
</UserControl>
